import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:xvideos/hj_page/mine_business/identity/mine_identity_page.dart';
import 'package:xvideos/hj_page/mine_business/mine_setting/bing_phone_page.dart';
import 'package:xvideos/hj_utils/widget_utils.dart';
import 'package:xvideos/tools_base/global_store/store.dart';
import 'package:xvideos/tools_base/widget/common_dialog.dart';

import '../../../assets_tool/app_colors.dart';
import '../../../hj_model/user/user_info_model.dart';

class AccountSaveAlert extends StatelessWidget {
  const AccountSaveAlert({super.key});

  @override
  Widget build(BuildContext context) {
    return CommonDialog(
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          Text(
            '账号凭证',
            style: TextStyle(
              fontSize: 20,
              color: Colors.white.withOpacity(0.9),
              fontWeight: FontWeight.w500,
            ),
          ),
          12.sizeBoxH,
          0.5.line,
          12.sizeBoxH,
          Column(
            children: [
              Text(
                '''受行业限制，APP无法正常使用时需升级，未绑定手机号码会导致账号信息丢失。 
请及时绑定手机/邮箱或保存账号凭证，以免VIP信息丢失，造成巨大财产损失！ 
账号丢失的用户可在 [我的]-设置-账号安全-扫码登录，原账号的VIP信息会转移至新账号上。''',
                style: TextStyle(color: Colors.white.withOpacity(.55), fontSize: 14, height: 1.7),
              ),
              12.sizeBoxH,
              InkWell(
                onTap: () {
                  Get.toNamed(BindPhonePage.routeName, arguments: PhonePageType.bind)?.then((value) async {
                    if (value != null) {
                      UserInfoModel? userInfo = await GlobalStore().updateUserInfo();
                      Navigator.pop(context, userInfo);
                    }
                  });
                },
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    Text(
                      '绑定手机号',
                      style: TextStyle(
                        color: Colors.white.withOpacity(.55),
                        fontSize: 14,
                      ),
                    ),
                    2.sizeBoxW,
                    Icon(
                      Icons.arrow_forward_ios_rounded,
                      size: 14.sp,
                      color: Color(0xffDCDCDC),
                    )
                  ],
                ),
              ),
              24.sizeBoxH,
              Row(
                children: [
                  InkWell(
                    onTap: () => Get.back(result: true),
                    child: Container(
                      alignment: Alignment.center,
                      height: 44,
                      width: 112,
                      decoration: BoxDecoration(borderRadius: BorderRadius.circular(3), color: Colors.white.withOpacity(.1)),
                      child: Text(
                        "我已保存",
                        style: TextStyle(color: Color(0xff989898), fontSize: 16, fontWeight: FontWeight.w500),
                      ),
                    ),
                  ),
                  12.sizeBoxW,
                  Expanded(
                    child: InkWell(
                      onTap: () {
                        Get.back();
                        Get.to(() => MineAccountIdentityPage(), duration: Duration.zero);
                      },
                      child: Container(
                        height: 44,
                        decoration: BoxDecoration(
                          borderRadius: BorderRadius.circular(3),
                          color: AppColors.actionRed,
                        ),
                        alignment: Alignment.center,
                        child: Text(
                          '保存凭证',
                          style: TextStyle(
                            color: Colors.white,
                            fontSize: 16,
                            fontWeight: FontWeight.w500,
                          ),
                        ),
                      ),
                    ),
                  )
                ],
              ),
            ],
          ),
        ],
      ),
    );
  }
}
